unit BW_CustObj;

{$mode delphi}{$H+}

interface

uses
  BW_CustomObj_Acc,
  BW_Handler,

  LW_CustObj,
  LW_Server ;

type
  TCustObjFlag  = (cofSchemaOk      = LWCOF_SCHEMA_OK      ,
                   cofViewportIndex = LWCOF_VIEWPORT_INDEX ,
                   cofNoDepthBuffer = LWCOF_NO_DEPTH_BUFFER,
                   cofOverlay       = LWCOF_OVERLAY        ,
                   cofXRay          = LWCOF_XRAY           ) ;
  TCustObjFlags = set of TCustObjFlag                      ;

  { TCustomObject }

  TCustomObject = class(TRenderHandler)
  protected
    function  GetHandlerType                      : String        ; override;

    function  HandlerActivate
              (      Local  : Pointer           ) : Integer       ; override;

    procedure CustomObjEvaluate
              (const Access : PLWCustomObjAccess) ;
    function  CustomObjFlags
              (const Void                       ) : UInt32        ;

  public
    destructor
              Destroy                             ;                 override;

    procedure Evaluate                            ;                 virtual ;
    function  SetFlags                            : TCustObjFlags ; virtual ;

    property  Painter : TCustomObjAccess read  FCustomObjAccess
                                         write FCustomObjAccess;
  end;

implementation

{ TCustomObject }

function  TCustomObject.GetHandlerType                      : String       ;
begin
  Result := LWCUSTOMOBJ_HCLASS;
end;

function  TCustomObject.HandlerActivate
                        (      Local  : Pointer           ) : Integer      ;
var
  CustObjLocal: PLWCustomObjHandler absolute Local;
begin
  CustObjLocal.Evaluate := Pointer(CustomObjEvaluate);
  CustObjLocal.Flags    := Pointer(CustomObjFlags   );

  Result := AFUNC_OK;
end;

procedure TCustomObject.CustomObjEvaluate
                        (const Access : PLWCustomObjAccess) ;
begin
  if not Assigned(FCustomObjAccess) then
    FCustomObjAccess := TCustomObjAccess.Create;

  FCustomObjAccess.Access := Access;

  Evaluate;
end;

function  TCustomObject.CustomObjFlags
                        (const Void                       ) : UInt32       ;
var
  Index : TCustObjFlag;
  Flags : UInt32 = 0  ;
begin
  for Index in SetFlags do
    Flags := Flags or Integer(Index);

  Result := Flags;
end;

destructor
          TCustomObject.Destroy                             ;
begin
  if Assigned(FCustomObjAccess) then
    FCustomObjAccess.Free;

  inherited Destroy;
end;

procedure TCustomObject.Evaluate                            ;
begin
end;

function  TCustomObject.SetFlags                            : TCustObjFlags;
begin
  Result := [];
end;

end.

